package core.main;

import core.config.EventMappings;
import core.controller.ActionController;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.ValidationException;

public class init implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		try {
			ActionController.eventMappings = EventMappings
					.unmarshal(new FileReader(sce.getServletContext()
							.getRealPath("WEB-INF\\eventmappings.xml")));
		} catch (ValidationException e) {
			Logger.getLogger(ActionController.class.getName()).log(
					Level.SEVERE, null, e);
		} catch (FileNotFoundException e) {
			Logger.getLogger(ActionController.class.getName()).log(
					Level.SEVERE, null, e);
		} catch (MarshalException ex) {
			Logger.getLogger(ActionController.class.getName()).log(
					Level.SEVERE, null, ex);
		}
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
	}
}